<template>
  <div class="app-container">
    <div class="listBox">
      <div class="listBox_head">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" @click="handleAdd">新增空投</el-button>
          </el-col>
        </el-row>
      </div>
      <el-table v-loading="loading" :data="airdropList" stripe border>
        <el-table-column label="序号" align="center" type="index" width="64px" />
        <el-table-column label="标题" align="center" prop="title" :show-overflow-tooltip="true" />
        <el-table-column label="执行时间" align="center" prop="executeTime" :show-overflow-tooltip="true" />
        <el-table-column label="空投人数" align="center" prop="customerCount" :show-overflow-tooltip="true"></el-table-column>
        <!-- <el-table-column label="状态" align="center" prop="status" :show-overflow-tooltip="true"></el-table-column> -->
        <el-table-column label="状态" align="center" prop="" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <dict-tag :options="airdropStatus" :value="scope.row.status" />
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="240" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="handleUpdate(scope.row)" v-if="scope.row.status==1">编辑</el-button>
            <el-button size="mini" type="text" @click="handleView(scope.row)">查看</el-button>
            <el-button size="mini" type="text" @click="handleAirdrop(scope.row)" v-if="scope.row.status==1">空投用户</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
    <Dialog ref="dialog" @refresh="getList"></Dialog>
    <DialogAirdrop ref="dialogAirdrop" @refresh="getList"></DialogAirdrop>
  </div>
</template>

<script>
  import {
    airdropList,
  } from "@/api/incentiveManagement";
  import Dialog from "@/views/incentiveManagement/prizeAirdrop/dialog";
  import DialogAirdrop from "@/views/incentiveManagement/prizeAirdrop/dialogAirdrop";
  export default {
    // dicts: ['equity_card_issue_type', 'equity_card_sell_status'],
    name: "",
    components: {
      Dialog,DialogAirdrop
    },
    data() {
      return {
        //日期
        date: [],
        // 遮罩层
        loading: false,
        // 导出遮罩层
        exportLoading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        airdropStatus:[],
        // 总条数
        total: 0,
        // 空投信息列表表格数据
        airdropList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
        },
        issueTypeLs: [], //发行方式下啦
        sellStatusLs: [], //状态下拉
      };
    },
    created() {
      this.getDict();
      this.getList();
    },
    methods: {
      //获取执行状态字典
      getDict() {
        var dictType = "airdrop_status";
        this.$getSelectList(dictType)
          .then((res) => {
            this.airdropStatus = res.result[0].dictList;
          })
          .finally(() => {
            this.loading = false;
          });
      },
      /** 查询空投信息列表 */
      getList() {
        this.loading = true;
        airdropList(this.queryParams).then(response => {
          this.airdropList = response.result.records;
          this.total = response.result.total;
          this.loading = false;
        });
      },
      // 表单重置
      reset() {
        this.date = []
        this.queryParams = {
          pageNum: 1,
          pageSize: 10,
        }
        // this.resetForm("form");
        this.handleQuery()
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        // this.resetForm("queryForm");
        this.reset();
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.$refs.dialog.open();
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.$refs.dialog.open(row.id, false);
      },
      /** 详情按钮操作 */
      handleView(row) {
        this.$refs.dialog.open(row.id, true);
      },
      /** 空投用户按钮操作 */
      handleAirdrop(row) {
        this.$refs.dialogAirdrop.open(row.id);
      },
    }
  };

</script>
<style scoped>
  .head {
    box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
    background-color: #fff;
    border-radius: 8px;
    padding: 20px 20px 0;
  }

  .listBox {
    box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
    background-color: #fff;
    border-radius: 8px;
    padding: 20px 20px;
    margin-top: 10px;
  }

  .listBox_head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
  }

</style>
